<% properties = @property_pattern.properties %>
<% pi = 0 %>
<% properties.each_with_index do |property, index| %>
  <% if property == @property %>
    <% pi = index %>
  <% end %>
<% end %>

<%= fields_for "property_pattern[properties_attributes][#{pi}][property_attributes_attributes][#{PropertyPatternPropertyAttribute.where(:property_pattern_property_id => @property_attribute.property_pattern_property_id).count - 1}]", @property_attribute do |f| %>
  <li class="property_attribute">
    <div>
      <%= f.label :presentation %>
      <%= f.text_field :presentation, :class => "property_attribute_presentation", :maxlength => 35, :size => 16, :node_id => "#{f.object.id}" %>
      <%= f.select :value_type, options_for_select([["#{t 'enumerations.property.value_type.value'}" => "value"], ["#{t 'enumerations.property.value_type.select'}" => "select"], ["#{t 'enumerations.property.value_type.choice'}" => "choice"]]) %>

      <%= f.hidden_field :id %>

      <%= f.hidden_field :node_parent_id, :class => "property_attribute_parent_id", :size => 4 %>
      <%= f.hidden_field :node_next_id, :class => "property_attribute_next_id", :size => 4 %>
      <%= f.hidden_field :node_prev_id, :class => "property_attribute_prev_id", :size => 4 %>
      <%= f.hidden_field :node_id, :class => "property_attribute_node_id", :size => 4, :value => @property_attribute.id %>

      <%= f.fields_for :property_value do |property_value| %>
        <%= property_value.label :value %>
        <%= property_value.text_field :value, :class => "property_value_value", :maxlength => 60, :size => 20 %>

        <%= property_value.collection_select :metric_id, Metric.all, :id, :presentation, :include_blank => true %>
      <% end %>

      <span style="float: right;"><%= link_to_remove_fields("Smazat vlastnost", f, "property_attribute") %></span>
    </div>
  </li>
<% end %>